package com.weaver.qfengx.api.qihoo;

import cn.hutool.crypto.asymmetric.RSA;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

/**
 * 奇虎360 查杀云API工具类测试
 */
public class FileScannerTest {

    private static FileScannerConfig fileScannerConfig = FileScannerConfig.build("http://127.0.0.1", "222", "333");

    public static void main(String[] args) throws FileNotFoundException {
        File file = new File("C:\\Users\\Qfeng\\Desktop\\down\\111.txt");
        RSA rsa = new RSA();

        // 调用方式一, 直接通过File
        FileScannerResult fileScannerResult = FileScanner.sampleQuerySync(fileScannerConfig, file);
        if (fileScannerResult.isHttpOK()) {
            if (fileScannerResult.isVirus()) {
                System.out.println("是病毒, level => " + fileScannerResult.getLevel());
            } else {
                System.out.println("level => " + fileScannerResult.getLevel());
            }
        } else {
            System.out.println("api请求异常 => http code " + fileScannerResult.getHttpCode() + " response =>  " + fileScannerResult.getResponse());
        }
        // 调用方式二，直接通过文件流
        fileScannerResult = FileScanner.sampleQuerySync(fileScannerConfig, new FileInputStream(file));
        if (fileScannerResult.isHttpOK()) {
            if (fileScannerResult.isVirus()) {
                System.out.println("是病毒, level => " + fileScannerResult.getLevel());
            } else {
                System.out.println("level => " + fileScannerResult.getLevel());
            }
        } else {
            System.out.println("api请求异常 => http code " + fileScannerResult.getHttpCode() + " response =>  " + fileScannerResult.getResponse());
        }
    }

}
